@extends('admin.master')

@section('style')
	<link rel="stylesheet" href="{{ url('css/bootstrap-datetimepicker.css') }}">
	<link rel="stylesheet" href="{{ url('js/bootstrap-select/bootstrap-select.min.css') }}">
@endsection

@section('top')
<div class="top-breadcrumb pull-left">{!! Breadcrumbs::render() !!}</div>
@endsection

@section('content')
	<div class="container-body" id="view">
	{!! Form::model($data, ['route' => ['admin.other-order.update', $data->id], 'method'=>'patch', 'class'=>'form-horizontal']) !!}
		<input name="referer" type="hidden" value="{{ request()->header('referer') }}">
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">订单类型：</label>
			<div class="col-sm-8 row">
				{!! Form::select('type', config('system')['other_order_type'], null, [
				'class'=>'form-control len150 selectpicker show-tick',
				'v-model' => 'type'
				]) !!}
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">生产类型：</label>
			<div class="col-sm-8 row">
				<label class="radio-inline"><input type="radio" name="ptype" value="1" v-model="product"> 定制单</label>
				<label class="radio-inline"><input type="radio" name="ptype" value="2" v-model="product"> PSD</label>
				<label class="radio-inline"><input type="radio" name="ptype" value="3" v-model="product"> 其他</label>
			</div>
		</div>
		<div class="web-label" v-show="product < 3">
			<div class="web-label-content">
				<div class="form-group">
					<label class="col-sm-4 control-label label-width">完成进度：</label>
					<div class="col-sm-8 row">
						{!! Form::select('progress', array_slice(config('system')['progress'], 1, null, true), null, ['class'=>'form-control len150']) !!}
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-4 control-label label-width">语言版本：</label>
					<div class="col-sm-8 row">
						{!! Form::select('languages[]', config('system')['language'], null, ['class'=>'form-control len lan-select', 'multiple'=>'multiple']) !!}
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-4 control-label label-width">语言进度：</label>
					<div class="col-sm-8 row">
						<div class="checkbox">
							<label class="text-success">{!! Form::checkbox('is_end', 1, null) !!} 语言版本全部完成</label> 
						</div>
					</div>
				</div>
				<div class="form-group" v-show="product == 1">
					<label class="col-sm-4 control-label label-width">设计确认时间：</label>
					<div class="col-sm-8 row">
						<div class="input-append date form-datetime len150">
							{!! Form::text('designed_at', $data->designed_at->toDateTimeString() > 0 ? $data->designed_at->format('Y-m-d') : '' , ['class'=>'form-control len150 datetimepicker-1', 'data-date-format'=>'yyyy-mm-dd']) !!}
							<i class="icon icon-date"></i>
						</div>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-4 control-label label-width">程序确认时间：</label>
					<div class="col-sm-8 row">
						<div class="input-append date form-datetime len150">
							{!! Form::text('produced_at', $data->produced_at->toDateTimeString() > 0 ? $data->produced_at->format('Y-m-d') : '' , ['class'=>'form-control len150 datetimepicker-2', 'data-date-format'=>'yyyy-mm-dd']) !!}
							<i class="icon icon-date"></i>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">
				<span class="text-danger">*</span> <span>客户名称：</span>
			</label>
			<div class="col-sm-6 row">
				{!! Form::text('name', null, ['class'=>'form-control len', 'data-rule'=>'required']) !!}
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">状态：</label>
			<div class="col-sm-8 row">
				{!! Form::hidden('status', null, ['class'=>'status-hidden']) !!}
				<div class="items-step">
					<ul>	
					@foreach(config('system.other_order_status') as $key=>$value)
						<li {!! $data->status >= $key ? 'class="active"' : '' !!} data-status="{{ $key }}"><span>{{ $value }}</span></li>
					@endforeach
					</ul>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">下单时间：</label>
			<div class="col-sm-8 row">
				<div class="input-append date form-datetime len150">
					{!! Form::text('created_at', $data->created_at->toDateTimeString() > 0 ? $data->created_at->format('Y-m-d') : '' , ['class'=>'form-control len150 datetimepicker-created', 'data-date-format'=>'yyyy-mm-dd']) !!}
					<i class="icon icon-date"></i>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">开始生产时间：</label>
			<div class="col-sm-8 row">
				<div class="input-append date form-datetime len150">
					{!! Form::text('started_at', $data->started_at->toDateTimeString() > 0 ? $data->started_at->format('Y-m-d') : '' , ['class'=>'form-control len150 datetimepicker-start', 'data-date-format'=>'yyyy-mm-dd']) !!}
					<i class="icon icon-date"></i>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">完成时间：</label>
			<div class="col-sm-8 row">
				<div class="input-append date form-datetime len150">
					{!! Form::text('finished_at', $data->finished_at->toDateTimeString() > 0 ? $data->finished_at->format('Y-m-d') : '' , ['class'=>'form-control len150 datetimepicker-finish', 'data-date-format'=>'yyyy-mm-dd']) !!}
					<i class="icon icon-date"></i>
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">
				<span>相关标签：</span>
			</label>
			<div class="col-sm-6 row">
				{!! Form::hidden('label', null, ['id'=>'label-content']) !!}
				<p class="form-control-static label-list">
					@foreach(config('system.tag.other_order') as $value)
					<a href="javascript:;" {!! $data->label == $value ? 'class="active"' : '' !!}>{{ $value }}</a>
					@endforeach
				</p>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">周期：</label>
			<div class="col-sm-8 row">
				{!! Form::number('days', null, ['class'=>'form-control len', 'placeholder'=>'要求完成的天数']) !!}
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">域名：</label>
			<div class="col-sm-8 row">
				<div class="input-group">
					<div class="input-group-addon">http://</div>
					{!! Form::text('domain', null, ['class'=>'form-control']) !!}
				</div>
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">临时网址：</label>
			<div class="col-sm-8 row">
				{!! Form::text('temp_url', null, ['class'=>'form-control len']) !!}
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">联系人：</label>
			<div class="col-sm-8 row">
				{!! Form::text('contact_people', null, ['class'=>'form-control len']) !!}
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">手机号：</label>
			<div class="col-sm-8 row">
				{!! Form::text('phone', null, ['class'=>'form-control len']) !!}
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">提成：</label>
			<div class="col-sm-8 row">
				{!! Form::number('commission', null, ['class'=>'form-control len', 'placeholder'=>'设计师的订单提成']) !!}
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">设计师：</label>
			<div class="col-sm-8 row">
				<span v-if="product != 2" class="inline-block">
					{!! Form::select('designer_id', $designer->prepend('选择设计师', 0), null, ['class'=>'form-control len100']) !!}
				</span>
				<span v-if="product < 3" class="inline-block ml5">
					{!! Form::select('programmer_id', $designer->prepend('选择制作员', 0), null, ['class'=>'form-control len100']) !!}
				</span>
				<span v-if="product < 3" class="inline-block ml5">
					{!! Form::select('inputer_id', $designer->prepend('选择录入员', 0), null, ['class'=>'form-control len100']) !!}
				</span>
			</div>)
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width">备注：</label>
			<div class="col-sm-8 row">
				{!! Form::textarea('remark', null, ['class'=>'form-control len500', 'rows'=>5]) !!}
			</div>
		</div>
		<div class="form-group">
			<label class="col-sm-4 control-label label-width"></label>
			<div class="col-sm-8 row">
				{!! Form::submit('提交', ['class'=>'btn btn-primary btn-submit']) !!}
			</div>
		</div>
	{!! Form::close() !!}
	</div>
@endsection

@section('foot')
<script src="{{ url('js/bootstrap-datetimepicker.js') }}"></script>
<script src="{{ url('js/nice-validator/jquery.validator.js?local=zh-CN') }}"></script>
<script src="{{ url('js/bootstrap-select/bootstrap-select.min.js') }}"></script>
<script src="{{ url('js/bootstrap-select/defaults-zh_CN.min.js') }}"></script>

<script type="text/javascript">

	$('.label-list').on('click', 'a', function() {
		$('.label-content').val();
	});

    $('.label-list').on('click', 'a', function(e) {
    	if ($(this).hasClass('active')) {
    		$('#label-content').val('');
    		$(this).removeClass('active');
    	} else {
    		$('#label-content').val($(this).text());
    		$(this).addClass('active').siblings().removeClass('active');
    	}
    });

    $('.datetimepicker-created').datetimepicker({
    	language: 'zh-CN',
    	autoclose: true,
    	minView: 'month'
    });	

    $('.datetimepicker-start').datetimepicker({
    	language: 'zh-CN',
    	autoclose: true,
    	minView: 'month'
    });	

    $('.datetimepicker-finish').datetimepicker({
    	language: 'zh-CN',
    	autoclose: true,
    	minView: 'month'
    });	

    $('.datetimepicker-1').datetimepicker({
    	language: 'zh-CN',
    	autoclose: true,
    	minView: 'month'
    });	

    $('.datetimepicker-2').datetimepicker({
    	language: 'zh-CN',
    	autoclose: true,
    	minView: 'month'
    });	


	$('.selectpicker').selectpicker();
	$('.lan-select').selectpicker();

	$('.items-step li').on('click', function() {
		$('.items-step li').addClass('active');
		$(this).nextAll().removeClass('active');

		$('.status-hidden').val($(this).data('status'));
	});

	new Vue({
		el: '#view',
		data: {
	    	type: 1,
	    	product: {{ $data->ptype }}
		},
		computed: {
			programmer: function() {
				return this.type == 2 || this.type == 3 || this.type == 11;
			} 
		}
	})

</script>
@endsection